<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<STYLE type="text/css">
*{
  margin:0px;
  padding:0px;
}
html,body{
   height:100%;
   width:100%;
   overflow:auto;
   overflow-y:auto;
}

</STYLE>
</head>
<body>
<div class="divfrist" id="usersetingpower_mainDiv" class="" style="width:100%;height:100%;">
						<div style="width:100%;height:0.7%;overflow:hidden;"></div>
						<div style="width:100%;height:98.6%;">
								<div style="width:0.4%;height:100%;float:left;overflow:hidden;"></div>
								<div style="width:99.2%;height:100%;float:left;">
									 <div style="border: 0px solid #9ABAE9;overflow: auto;height:100%;max-height:100%;">
													<!--内容区 -->
													<div style="width:100%;height:100%;">		
														 <table  id="setuser_table" style="border: 0px; width: 100%"></table>
													</div>
													<div id="setuser_tb" style="overflow: hidden; padding-left: 10px; padding-top: 5px;padding-bottom: 5px;">
															<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true"  onclick="window.setUserPower.setUserPower()">设为桌面默认显示</a>|| 			  
													
													</div>	
														
													<!--内容区 -->
									 </div>
								</div>
								<div class="width:0.37%;height:100%;float:left;overflow:hidden;"></div>
						</div>
						<div class="width:100%;height:0.6%;overflow:hidden;"></div>
</div>
</body>
<script type="text/javascript">
(function(){
			  //增加用户
		    var content="";
			
			//初始化用户表table
			function inituserGrid(){
				$.ajax({
					   type: "POST",
					   url : '${pageContext.request.contextPath}/sys/sysUserAction!getUserALlPower_url.action',					  
					   dataType:'json',
					   success: function(msg){
						   $('#setuser_table').datagrid("loadData",msg);
					   }
					});
				
			}
			//创建easyUI userGrid
			function createGriduser(){
				$('#setuser_table').datagrid({
					title:'权限列表',
					toolbar:"#setuser_tb",
					fit: true,
					rownumbers: true,
					striped: true,
					singleSelect:false,
					animate:true,
					loadMsg:'权限正在加载',
					//collapsible:true,
					idField:'sysPower_id',
					fitColumns:true,	
						columns:[[
						     {field:'sysPower_id',width:120,checkbox:true},
						     {field:'sysPower_name',title:'权限名称',width:120},						
							 {field:'sysPower_state',title:'权限状态',formatter : function(value, row, index){							
								if(row.sysPower_state=="0"){
									return  '<font color="red">禁用</font>';
								}
								if(row.sysPower_state=="1"){
									return  '<font color="green">启用</font>';
								}
							return "";
						},width:120},
						]]
					});
			}
			
			$(function(){	
					$.parser.parse('#usersetingpower_mainDiv'); 
				   //创建用户表格
					//初始化用户数据
					createGriduser();
					inituserGrid();
			});
			function setUserPower(){		
				delCookie("${sysUser.sysUserId}_1");
				var arr=$('#setuser_table').datagrid("getSelections");	
				var userPowersetingArr = new Array();
				for(var i=0;i<arr.length;i++){				
					userPowersetingArr.push(arr[i].sysPower_id);
				}
				//为什么要这么做？自己去想吧
				 
				SetCookie("${sysUser.sysUserId}_1",userPowersetingArr);
				alert("设置成功");
			}
			window["setUserPower"]={};
			window["setUserPower"]["setUserPower"]=setUserPower;
	
})();
</script>
</html>